/*
 * @Author: EltonLi lijiaming@uavi-tech.com
 * @Date: 2023-09-12 18:10:03
 * @LastEditors: LVGRAPE
 * @LastEditTime: 2025-07-10 17:05:04
 * @FilePath: \zino-fc-v4\applications\ZINO_FC_V4.0\usercmd\usercmd.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef __USERCMD_H__
#define __USERCMD_H__

#ifdef __cplusplus
extern "C"
{
#endif

#include <rtdef.h>
#include <stdbool.h>
#include "fc_sensors.h"
#include "pid.h"

    // 期望值数据
    typedef struct
    {
        attitude_t angle;   // 角度
        attitude_t rate;   // 角度
        Axis_3_float_t vel; // 速度
        Axis_3_float_t pos; // 位置
        bool manual[3]; // 手动控制
    } setPoint_t;

    typedef enum
    {
        RC_BAT = 0,
        RC_RLR,
        RC_RUD,
        RC_LLR,
        RC_LUD,
        RC_KEY_VALUE,
        RC_MODE,
        RC_COUNT,
    } RC_STICK_BUTTOM_E;

    typedef enum
    {
        RC_LT = 1 << 0,
        RC_RT = 1 << 1,
        RC_LK = 1 << 2,
        RC_RK = 1 << 3,
        RC_PWRK = 1 << 4,
    } RC_BUTTOM_CTRL_E;

    typedef enum
    {
        CMD_ROLL = 0,
        CMD_PITCH,
        CMD_YAW,
        CMD_THROTTLE,
        CMD_COUNT
    } CommandList_e;

    typedef struct
    {
        uint16_t rc_rssi;
        int16_t rcChannel[8]; //[-RC_MID, RC_MID], raw rc control value, remote control channel
        int16_t proChannel[4];//from mixly
        int16_t cmChannel[4];//direct to motor
        int16_t maxYawRate;
        int16_t maxRollAndPicthAngle;
        int16_t maxVel_Z;
        float rcDeflection[5];//scale rcChannel to range [-1.0, 1.0]
        float headFreeCh[5];

    } usercmd_t;

    extern setPoint_t setPoint;
    extern usercmd_t usercmd;
    extern bool ReachTakingOffHeight;
    // extern bool RollFlag;
    // extern bool PitchFlag;
    // void pid_rc_param_set(struct pid_param *param);
    void setpoint_handle(setPoint_t *setpoint, usercmd_t *usercmd, zdrone_state_t *state);
    float get_landingThrushold(void);
    float get_vx_kp_boost(void);
    float get_vy_kp_boost(void);
    float get_ground_height(void);
    extern uint8_t testoptQual;

#ifdef __cplusplus
}
#endif

#endif
